Visual Basic (Declaration) | |
---|---|
Public Function New( _ ByVal executable As String, _ ByVal ParamArray args() As String _ ) |
C# | |
---|---|
public ProcessRunner( string executable, params string[] args ) |
Parameters
- executable
- args
Library/Library.Test/TestProcessRunner.cs
C# | Copy Code |
---|---|
string tempfile = Path.GetTempFileName(); try { ProcessRunner runner = new ProcessRunner("cmd.exe", "/C", "ECHO", "Hello", ">{0}"); runner.StartFormatArgs(tempfile); Assert.AreEqual(0, runner.ExitCode); string output = File.ReadAllText(tempfile).Trim(); Assert.AreEqual("Hello", output); File.Delete(tempfile); Assert.AreEqual(0, runner.RunFormatArgs(tempfile)); output = File.ReadAllText(tempfile).Trim(); Assert.AreEqual("Hello", output); } finally { File.Delete(tempfile); } |
VB.NET | Copy Code |
---|---|
Dim tempfile As String = Path.GetTempFileName() Try Dim runner As New ProcessRunner("cmd.exe", "/C", "ECHO", "Hello", ">{0}") runner.StartFormatArgs(tempfile) Assert.AreEqual(0, runner.ExitCode) Dim output As String = File.ReadAllText(tempfile).Trim() Assert.AreEqual("Hello", output) File.Delete(tempfile) Assert.AreEqual(0, runner.RunFormatArgs(tempfile)) output = File.ReadAllText(tempfile).Trim() Assert.AreEqual("Hello", output) Finally File.Delete(tempfile) End Try |
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
Reference
ProcessRunner ClassProcessRunner Members
Overload List